package com.ry.ryshopweb.vo;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.util.List;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class PageObject<T> implements Serializable {

    private static final long serialVersionUID = -3406681911796312869L;
    //总记录数
    private Integer rowCount;
    //当前页记录
    private List<T> records;
    //当前页码值
    private Integer pageCurrent;
    //页面大小(每页最多显示多少记录)
    private Integer pageSize;
    //总页数
    private Integer pageCount;

    /**
     *
     * @param rowCount 总记录数
     * @param records 结果list
     * @param pageCurrent 当前页码值
     * @param pageSize 页数大小
     */
    public PageObject(Integer rowCount, List<T> records, Integer pageCurrent, Integer pageSize) {
        this.rowCount = rowCount;
        this.records = records;
        this.pageCurrent = pageCurrent;
        this.pageSize = pageSize;
        this.pageCount=this.rowCount/this.pageSize;
        if (this.rowCount%this.pageSize!=0){
            pageCurrent++;
        }
    }
}
